Cursor Editing
Volume Number: 1
Issue Number: 9
Column Tag: Basic School
"A Fat Bits Approach to Cursor Editing
By Dave Kelly, Hybrids Engineer, MacTutor Editorial Board
Let's take a look at one of the Macintosh ROM routines which can be called from
MSBASIC (version 2.0). By using the method described here, you can customize your
own cursors for use within your programs.
Pages 298 and 299 of the MS BASIC manual explain the Mouse Cursor Handling
Routines. The program 'Cursor Editor' in this article demonstrates how to build your
own cursor using the CALL SETCURSOR (VARPTR( cursor %(0))) function. It would
be helpful to enter the program and run it as you read the explanation here.
Fig. 1 Cursor Edit Program Menu
When you run the program, the main BASIC menus are replaced by a new File and
Cursor menu. The Cursor menu allows you to edit the current custom cursor. The
Arrow is the default cursor and cannot be edited unless you duplicate it as a custom
cursor of your own. Choosing 'Hand' sets the cursor to a hand. An examination of the
'Hand' routine at the end of the program may help you to understand how the
cursor%(0) array is setup.
By selecting 'Arrow' in the cursor menu you may clear the cursor to be edited to
a blank. The editor is set to a blank (i. e. no cursor) when the program starts. Select
'Edit Cursor' from the menu. The bit parameters for the screen grid are set up and a
blank grid is printed on the screen.
Fig. 2
Now just point and click the mouse to select what the cursor will look like. The
program will appear to run a bit slow here while the correct bit is being selected.
This takes longer in Basic than in most other languages, so be patient. When the
cursor is finished click the OK button.
Now a new grid comes up to create a mask for our new cursor. The cursor mask
selects which bits behind the cursor will be allowed to be seen through the cursor (the
entire 16X16 grid). The program allows you to exper-iment with different masks
until you get it just right. To test it out you can move the cursor over a black area of
the screen and then over a white area and see what part of the background is allowed to
be seen through the cursor. It is purely subjective so you can keep on trying till you
are happy with it. For our example, I have filled in the inside of the cursor to make
the mask. Any pixels of the screen which are behind the mask will not be allowed to be
displayed. Click the OK button to continue.
Fig. 3 Creating the Mask
Next we set the hot spot of the cursor. The hot spot is the active area of the
cursor that determines where it is pointing to. It is the intersection of the corners of
the pixels. For our example, we want the hot spot to be at the tip of the pencil so we
click there. A small square appears to mark the spot. You may want to try other
locations for the hot spot if you don't quite understand the significance of the hot spot.
Click OK to continue.
Fig. 4 Setting the Hot Spot
Now the new cursor will appear. WARNING: If the cursor which was defined had
no pixels selected (i. e. a blank cursor), then it will be very difficult to select
anything from this point on because you will not be able to see the cursor. If this
happens you may have to abort (use command-period to halt a basic program). Basic
will reinitialize the arrow cursor when you exit the program.
Your new cursor can now be stored in a file on the disk by using the file menu and
loaded at a later time. The load routine may be copied for use in your own program to
read in a custom cursor for your own programs. After the cursor data is stored to
disk, the program will change the file type to "CURS" to enable the load routine to
recognize only those files which contain cursor data. Any filename type may be
changed so that the routine which reads the data may only select files of the same type.
Hopefully this program provides an easy way to customize your own cursors. A
good way to create a library of cursors is to do a screen dump to disk of the MacPaint
screen. Then load the dumped sceen and look at the cursors used by MacPaint using Fat
Bits and dump each of them to the printer from the Fat Bit screen. Then the cursor can
be copied bit by bit into the cursor editor program and saved. The program is
available on disk if you don't want to have to type. Have fun!!!
' Cursor Editor
' By Dave Kelly